home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Snippets / BGHSorting / README < prev   
Encoding:
Text File  |  1994-11-28  |  751 b   |  17 lines  |  [TEXT/R*ch]

  1. Newsgroups: comp.sys.mac.programmer
  2. From: Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  3. Date: Sun, 7 Aug 1994 16:39:13 +1200 (NZST)
  4.  
  5. My own sort routine (which I wrote for the Mac in 1987 and haven't
  6. modified since, btw) chooses the pivot value as the median of the
  7. first, middle and last elements in the partition.  It also minimises
  8. use of stack space by sorting the smaller of the two new partitions
  9. recursively (which guarantees no more than log2(n) recursion levels
  10. and usually more like log3(n)), then iterating to sort the larger one.
  11. It also switches to a selection sort once the number of elements in
  12. a partition is small.
  13.  
  14. I think I've got some good engineering decisions in there :-)
  15.  
  16. I include it below and hereby place it in the public domain.
  17.